import Vue from 'vue'
import VueRouter from 'vue-router'
import ApiPost from './api/index.js'
import App from './App.vue'
import insuranceCompany from './containers/insuranceCompany.vue'
import insProductList from './containers/insProductList.vue'
import addInsurance from './containers/insuranceForm.vue'
import './js/flexible.js'
import './js/flexible_css.js'
import './js/zepto.js'
import './js/native_h5.js'
import './js/vueLocalstroge.js'
// 1. Use plugin.
// This installs <router-view> and <router-link>,
// and injects $router and $route to all router-enabled child components
Vue.use(VueRouter)

// 2. Define route components
//todo

// 3. Create the router
const router = new VueRouter({
  mode: 'hash',
  base: __dirname,
  routes: [
  	{ path: '/', 
      component: insuranceCompany,
      beforeEnter: (to, from, next) => {
        window.YztApp.ubt('我的保险','添加保单_打开_保险公司列表页',{})
        next()
      }
    },
    { path: '/insuranceCompany', 
      component: insuranceCompany ,
      beforeEnter: (to, from, next) => {
        window.YztApp.ubt('我的保险','添加保单_打开_保险公司列表页',{})
        next()
      }
    },
    { path: '/insProductList', 
      component: insProductList ,
      beforeEnter: (to, from, next) => {
        window.YztApp.ubt('我的保险','添加保单_打开_保险产品列表页',{})
        next()
      }
    },
    { path: '/addInsurance', 
      component: addInsurance ,
      beforeEnter: (to, from, next) => {
        window.YztApp.ubt('我的保险','添加保单_打开_保单信息输入页',{})
        next()
      }
    }
  ]
})
document.body.onscroll = function(e){
  e.preventDefault();
}
router.beforeEach((to, from, next) => {
  switch(to.path){
    case '/insuranceCompany' :
      window.YztApp.setTitle('选择保险公司');
      document.title = '选择保险公司'
      break;
    case '/insProductList':
      window.YztApp.setTitle('选择保险产品')
      document.title = '选择保险产品'
      break;
    case '/addInsurance':
      window.YztApp.setTitle('保单编辑')
      document.title = '保单编辑'
      break;
    default :
      window.YztApp.setTitle('选择保险公司')
      document.title = '选择保险公司'
  }
  next()
})
// 4. Create and mount root instance.
// Make sure to inject the router.
// Route components will be rendered inside <router-view>.
new Vue({
  router,
  render: h =>h(App)
}).$mount('#app');

//隐藏容器右上角的点点点
window.YztApp.showOrHideNavMoreBtn(false);
